//
//  BRAPIManger.m
//  ZhuShou
//
//  Created by Dejun Liu on 15/11/4.
//  Copyright © 2015年 jw. All rights reserved.
//

#import "BRAPIManger.h"
#import "SqliteManager+API.h"

#define kTypeAccount @"account"
#define kTypeBusiness @"business"

@implementation BRAPIManger

JW_SINGLETON_IMPL(BRAPIManger)

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.allAPIs = [[SqliteManager sharedInstance]getAPIs];
    }
    return self;
}

- (NSArray *)getAccountAPIs
{
    NSMutableArray *array = [NSMutableArray array];
    [self.allAPIs enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ZSAPI *api = obj;
        if ([api.senv isEqualToString:kENVCurrent] && [api.stype isEqualToString:kTypeAccount]) {
            [array addObject:api];
        }
    }];
    return array;
}

- (NSArray *)getBusinessAPIs
{
    NSMutableArray *array = [NSMutableArray array];
    [self.allAPIs enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ZSAPI *api = obj;
        if ([api.senv isEqualToString:kENVCurrent] && [api.stype isEqualToString:kTypeBusiness]) {
            [array addObject:api];
        }
    }];
    return array;
}

@end
